﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Tea.Parser {

    /// <summary>
    /// 表示一个函数或一个脚本。
    /// </summary>
    public interface IScopeNode {

        NodeList<Statement> Statements {
            get;
        }

        void AddSymbol(string name, TokenType declType);

        TokenType GetSymbol(string name);

        IScopeNode GetDefinedBlock(string name);

        Location StartLocation { get; }

        Location EndLocation { get; }

        void AddFunction(FunctionDeclaration fn);

        NodeList<FunctionDeclaration> Functions { get; }
    }

    /// <summary>
    /// 表示最高级别的脚本块。
    /// </summary>
    public class Script :Block, IScopeNode {

        public Script(Location location)
            : base(null, location) {
        }

        public override void Write(CodeWriter writer) {
            foreach (Statement s in Statements) {
                s.Write(writer);
            }
        }

    }
}
